package pr.iceworld.fernando.commonbase.model;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public enum Status implements BaseValue, ModelBase {
    /**
     * 有效
     */
    A(1),
    /**
     * 无效
     */
    NA(0),
    /**
     * 已删除
     */
    DD(-1);


    private static Map<Integer, Status> valueMap = new HashMap<>();

    static {
        for(Status status : Status.values()) {
            valueMap.put(status.value, status);
        }
    }

    private int value;
    Status(int value) { this.value = value; }

    @Override
    public int getValue() { return this.value; }

    public static Status getByValue(int value) {
        Status result = valueMap.get(value);
        if (Objects.isNull(result)) {
            throw new IllegalArgumentException("No element matches " + value);
        }
        return result;
    }
}
